
//ATmega103/128
#define     SPI_PORT           PORTB
#define     SPI_PORT_DIR       DDRB
#define     SPI_SCK            PB1                      // SPI signals
#define     SPI_MOSI           PB2
#define     SPI_MISO           PB3



void SPI_init(void)
{
SPI_PORT_DIR|=((1<<SPI_SCK) | (1<<SPI_MOSI));             // set SPI lines as input or output
SPI_PORT_DIR|=~(1<<SPI_MISO);                             
SPCR = 0x5f;                                              // set SPI configuration
} 

void spi_wait(void)                                       // wait for data from SPI 
{
 while (!SPSR);
}
 
